Copy and paste redeemed
نویسندگان
چکیده
Software development relies critically on code reuse, which software engineers typically realise through handwritten abstractions, such as functions, methods, or classes. However, such abstractions can be challenging to develop and maintain. One alternative form of re-use is copy-paste-modify, a methodology in which developers explicitly duplicate source code to adapt the duplicate for a new purpose. We have found that copy-paste-modify can be substantially faster than manual abstraction, and past research strongly suggests that it is a popular technique among software developers. We therefore propose that software engineers should forego hand-written abstractions in favour of copying and pasting. However, empirical evidence shows that copy-paste-modify complicates software maintenance, leading to bugs. To address this concern, we propose a software tool that merges together similar pieces of code and automatically creates suitable abstractions. This allows software developers to get the best of both worlds: custom abstraction together with easy re-use. To demonstrate the feasibility of our approach, we have implemented and evaluated a prototype merging tool for C++ on a number of near-clones in popular Open Source packages. We define near-clones as any set of method definitions that differ from each other in a few AST nodes. We found that maintainers find our algorithmically created abstractions to be largely preferable to existing duplicated code.
منابع مشابه
Copy - Paste Redeemed 1
Software evolves continuously. As software evolves, it’s code bases require implementations of new features. These new functionalities are sometimes mere extensions of existing functionalities with minor changes. A commonly used method of extending an existing feature into a similar new feature is to copy the existing feature and modify it. This method of extending feature is called “Copy-paste...
متن کاملCopy-paste Trees and Their Growth Rates
In this paper, we describe a copy-and-paste method for constructing a class of infinite self-similar trees. A copy-paste tree is constructed by repeatedly attaching copies of a finite tree (called a generator) to certain designated attachment vertices. We show that each generator has an associated nonnegative matrix which can be used to determine a formula for the growth function of the copy-pa...
متن کاملCP-Miner: A Tool for Finding Copy-paste and Related Bugs in Operating System Code
Copy-pasted code is very common in large software because programmers prefer reusing code via copy-paste in order to reduce programming effort. Recent studies show that copy-paste is prone to introducing bugs and a significant portion of operating system bugs concentrate in copy-pasted code. Unfortunately, it is challenging to efficiently identify copy-pasted code in large software. Existing co...
متن کاملAutoComPaste: Auto-Completing Text as an Alternative to Copy-Paste
The copy-paste command is a fundamental and widely used operation in daily computing. It is generally regarded as a simple task but the process can become tedious when frequent window switching is required to copy-paste across different documents. Autocompletion is another popular operation aimed at reducing users’ typing effort. It contrasts to copy-paste by allowing for text completion withou...
متن کاملEthnographic Study of Copy and Paste Programming Practices in OOPL
When programmers develop and evolve software, they frequently copy and paste (C&P) code from an existing code base, or sources such as web pages or documentation. We believe that programmers follow a small number of well defined C&P usage patterns when they program, and understanding these patterns would enable us to design tools to improve the quality of software. We conducted an ethnographic ...
متن کامل